<?php $this->load->view('layout/header'); ?>
<script type="text/javascript" charset="utf-8" src="/static/bk/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/bk/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/bk/ueditor/lang/zh-cn/zh-cn.js"></script>

<form runat="server" action="<?php echo $post_url; ?>" id="form1" method="post">
    <div id="container">
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table_form">
            <tr class="table_form_title">
                <td colspan="2">
                    <span id="lblTitle"><?php echo isset($class['classid'])?'修改':'添加';?></span>栏目
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    <span class="star">*</span>语言版本：
                </td>
                <td>
                    <select name="configid" id="configid">
                        <option value="-1">请选择</option>
                        <?php foreach ($config as $k => $v) { ?>
                            <option <?php echo $class['configid'] == $v['configid'] ? 'selected="selected" ' : ''; ?>value="1"><?php echo $v['languagever']; ?></option>
                        <?php } ?>
                    </select>
                    <span id="configid_tips" style="color:Red;display:none;">请选择</span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td align="right" style="width: 15%">
                    所属父级：
                </td>
                <td>
                    <span id="lblParent">根结点 
                        <?php
                        foreach ($node_list as $k => $v) {
                            echo ' > ' . $v['classname'] . '  ';
                        }
                        ?></span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    <span class="star">*</span>栏目名称：
                </td>
                <td>
                    <input name="classname" type="text" id="classname" value="<?php echo $class['classname']; ?>"/>
                    <span id="classname_tips" style="color:Red;display:none;">不能为空</span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    <span class="star">*</span>英文名称：
                </td>
                <td>
                    <input name="enname" type="text" id="enname" value="<?php echo $class['enname']; ?>"/>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    <span class="star">*</span>链接名称：
                </td>
                <td>
                    <input name="classlinkname" type="text" id="classlinkname" value="<?php echo $class['classlinkname']; ?>"/>.html
                    <a href="javascript:void(0);" onclick="javascript:GetPinYin('classname', 'classlinkname')">[获取栏目名称的拼音]</a>
                    <span id="classlinkname_tips" style="color:Red;display:none;">不能为空</span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    <span class="star">*</span>栏目属性：
                </td>
                <td>
                    <select name="classpropertyid" id="classpropertyid">
                        <option value="-1">请选择</option>
                        <?php foreach ($class_property as $k => $v) { ?>
                            <option <?php echo $class['classpropertyid'] == $v['classpropertyid'] ? 'selected="selected" ' : ''; ?>value="<?php echo $v['classpropertyid'] ?>"><?php echo $v['propertyname'] ?></option>
                        <?php } ?>
                    </select>
                    <span id="classpropertyid_tips" style="color:Red;display:none;">请选择</span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    <span class="star">*</span>栏目模板：
                </td>
                <td>
                    <select name="classtemplateid" id="classtemplateid">
                        <option value="-1">请选择</option>
                        <?php foreach ($class_template as $k => $v) { ?>
                            <option <?php echo $class['classtemplateid'] == $v['classtemplateid'] ? 'selected="selected" ' : ''; ?>value="<?php echo $v['classtemplateid'] ?>"><?php echo $v['templatename'] ?></option>
                        <?php } ?>
                    </select>
                    <span id="classtemplateid_tips" style="color:Red;display:none;">请选择</span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    栏目图片：
                </td>
                <td>
                    <input name="classpic" type="text" id="classpic" value="<?php echo $class['classpic'] ?>" />
                    <input type="button" value="上传图片" onclick="upload_file('classpic');" />
                    <input type="button" value="选择图片" onclick="selete_file('classpic');" />
                    <input type="button" value=" 预览 " onclick="preview_file('classpic');" />
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    自定义链接：
                </td>
                <td>
                    <input name="linkurl" type="text" id="linkurl" value="<?php echo $class['linkurl'] ?>"/>
                    <select name="target" id="target">
                        <option <?php echo $class['target'] == '_blank' ? 'selected="selected" ' : ''; ?>value="_blank">新窗口</option>
                        <option <?php echo $class['target'] == '_parent' ? 'selected="selected" ' : ''; ?>value="_parent">父窗口</option>
                        <option <?php echo $class['target'] == '_self' ? 'selected="selected" ' : ''; ?>value="_self">本窗口</option>
                        <option <?php echo $class['target'] == '_top' ? 'selected="selected" ' : ''; ?>value="_top">整页</option>

                    </select>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    <span class="star">*</span>缩略图设置：
                </td>
                <td>
                    宽：<input name="thumbwidth"  num="true" type="text" value="<?php echo $class['thumbwidth'] ?>" id="thumbwidth" style="width:80px;" />px 
                    高：<input name="thumbheight"  num="true" type="text" value="<?php echo $class['thumbheight'] ?>" id="thumbheight" style="width:80px;" />px
                    <span id="thumbwidth_tips" style="color:Red;display:none;">不能为空</span>
                    <span id="thumbwidth_num_tips" style="color:Red;display:none;">只能为数字</span>
                    <span id="thumbheight_tips" style="color:Red;display:none;">不能为空</span>
                    <span id="thumbheight_num_tips" style="color:Red;display:none;">只能为数字</span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    设置：
                </td>
                <td>
                    <input id="isgotofirst" value="1" type="checkbox" name="isgotofirst" <?php echo $class['isgotofirst'] == 1 ? 'checked="checked" ' : ''; ?> /><label for="chkIsGoToFirst">当有子栏目时,是否跳转到第一个子栏目</label>
                    <input id="isshownav" value="1"type="checkbox" name="isshownav" <?php echo $class['isshownav'] == 1 ? 'checked="checked" ' : ''; ?>/><label for="chkIsShowNav">是否显示在主导航</label>
                </td>
            </tr>

            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    SEO标题：
                </td>
                <td>
                    <input name="seotitle" type="text" value="<?php echo $class['seotitle'] ?>"/>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    关键字：
                </td>
                <td>
                    <input name="keywords" type="text" value="<?php echo $class['keywords'] ?>"/>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    栏目描述：
                </td>
                <td>
                    <textarea name="description" rows="8" cols="40" id="txtDescription"><?php echo $class['description'] ?></textarea>
                </td>
            </tr>
            <tr id="trSingle" class="table_form_row">
                <td style="width: 15%" align="right">
                    单页面内容：
                </td>
                <td>
                    <script id="classcontent" type="text/plain" style="width: 100%; height: 350px;"><?php echo $class['classcontent'] ?></script>
                </td>
            </tr>

            <tr class="table_form_row">
                <td align="right">&nbsp;</td>
                <td>
                    <a href="javascript:void(0);" class="a_config">栏目参数设置(对列表有效)</a>
                </td>
            </tr>
            <?php if(isset($class['classid'])){ ?>
            <tr class="table_form_row table_form_classconfig">
                <td align="right">
                </td>
                <td>
                    <input id="isupdatesubclassconfig" type="checkbox" name="isupdatesubclassconfig" value="1" />
                    <label for="isupdatesubclassconfig">同步更新到子栏目(相同栏目属性)</label>
                </td>
            </tr>
            <?php } ?>
            <tr class="table_form_row table_form_classconfig">
                <td align="right">
                    <span class="star">*</span>分页记录数：
                </td>
                <td>
                    <input name="pagesize" type="text" num="true" value="<?php echo $class['classconfig']['pagesize']; ?>" id="pagesize"/>
                    <span id="pagesize_tips" style="color:Red;display:none;">不能为空</span>
                    <span id="pagesize_num_tips" style="color:Red;display:none;">只能为数字</span>
                </td>
            </tr>
            <tr class="table_form_row table_form_classconfig">
                <td align="right">
                    <span class="star">*</span>显示记录总数：
                </td>
                <td>
                    <input name="topnum" type="text" num="true" value="<?php echo $class['classconfig']['topnum']; ?>" id="topnum" />注：为0时显示全部记录
                    <span id="topnum_tips" style="color:Red;display:none;">不能为空</span>
                    <span id="topnum_num_tips" style="color:Red;display:none;">只能为数字</span>
                </td>
            </tr>
            <tr class="table_form_row table_form_classconfig">
                <td align="right">
                </td>
                <td>
                    <input id="isshowsub" value="1" <?php echo $class['classconfig']['isshowsub'] == 1 ? 'checked="checked" ' : ''; ?>type="checkbox" name="isshowsub" /><label for="chkIsShowSub">是否显示子栏目记录</label>
                    <input id="isonlyrecommend" value="1" <?php echo $class['classconfig']['isonlyrecommend'] == 1 ? 'checked="checked" ' : ''; ?>type="checkbox" name="isonlyrecommend" /><label for="chkIsOnlyRecommend">是否只显示推荐记录</label>
                </td>
            </tr>
            <tr class="table_form_row table_form_classconfig">
                <td align="right">
                    <span class="star">*</span>排序方法：
                </td>
                <td>
                    <select name="orderfield" id="orderfield">
                        <option <?php echo $class['classconfig']['orderfield'] == 'addtime' ? 'selected="selected" ' : ''; ?>value="AddTime">按时间</option>
                        <option <?php echo $class['classconfig']['orderfield'] == 'listid' ? 'selected="selected" ' : ''; ?>value="ListID">按排序号</option>

                    </select>
                    <select name="orderkey" id="orderkey">
                        <option <?php echo $class['classconfig']['orderkey'] == 'desc' ? 'selected="selected" ' : ''; ?>value="desc">倒序</option>
                        <option <?php echo $class['classconfig']['orderkey'] == 'asc' ? 'selected="selected" ' : ''; ?>value="asc">顺序</option>
                    </select>
                </td>
            </tr>
            <tr class="table_form_row table_form_classconfig">
                <td align="right">
                    <span class="star">*</span>标题字数：
                </td>
                <td>
                    <input name="titlenum" type="text" num="true" value="<?php echo $class['classconfig']['titlenum']; ?>" id="titlenum" />注：为0时显示全部
                    <span id="titlenum_tips" style="color:Red;display:none;">不能为空</span>
                    <span id="titlenum_num_tips" style="color:Red;display:none;">只能为数字</span>
                </td>
            </tr>
            <tr class="table_form_row table_form_classconfig">
                <td align="right">
                    <span class="star">*</span>简单描述字数：
                </td>
                <td>
                    <input name="descnum" num="true" type="text" value="<?php echo $class['classconfig']['descnum']; ?>" id="descnum" />注：为0时显示全部
                    <span id="descnum_tips" style="color:Red;display:none;">不能为空</span>
                    <span id="descnum_num_tips" style="color:Red;display:none;">只能为数字</span>
                </td>
            </tr>
            <tr class="table_form_row table_form_classconfig">
                <td align="right">
                    <span class="star">*</span>详细链接名称：
                </td>
                <td>
                    <input name="datalink" type="text" value="<?php echo $class['classconfig']['datalink']; ?>" id="datalink" />$id.html
                    <span id="datalink_tips" style="color:Red;display:none;">不能为空</span>
                </td>
            </tr>
            <tr class="table_form_row table_form_classconfig">
                <td align="right">
                    列表样式类名称：
                </td>
                <td>
                    <input name="styleclass" value="<?php echo $class['classconfig']['styleclass']; ?>" type="text" id="styleclass" />
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    <span class="star">*</span>排序号：
                </td>
                <td>
                    <input name="listid" num="true" type="text" value="<?php echo $class['listid'] ?>" id="listid" />
                    <span id="listid_tips" style="color:Red;display:none;">不能为空</span>
                    <span id="listid_num_tips" style="color:Red;display:none;">只能为数字</span>
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    是否关闭：
                </td>
                <td>
                    <span id="radIsClose">
                        <input id="isclose" type="radio" name="isclose" value="1" <?php echo $class['isclose'] == 1 ? 'checked="checked" ' : ''; ?>/>
                        <label for="radIsClose_0">是</label>
                        <input id="radIsClose_1" type="radio" name="isclose" value="0" <?php echo $class['isclose'] == 0 ? 'checked="checked" ' : ''; ?>/>
                        <label for="radIsClose_1">否</label>
                    </span>
                </td>
            </tr>
            <tr class="table_form_btn">
                <td align="right">
                    <div id="hiddendiv" style="display: none;"></div>
                </td>
                <td>
                    <input type="submit" name="btnSave" value="保存" id="btnSave"/>
                    <input type="button" name="Submit" value="返回" onclick="javascript:history.go(-1);" />
                    <span id="errMsg" style="color:Red;"></span>
                </td>
            </tr>
        </table>
    </div> 

</form>
<script>
    var ue = UE.getEditor('classcontent', {textarea: 'classcontent'});
    $(".a_config").toggle(function() {
        $(".table_form_classconfig").show();
    }, function() {
        $(".table_form_classconfig").hide();
    });
    var is = true;
    $('#configid,#classpropertyid,#classtemplateid').change(function() {
        if (this.id == 'classpropertyid') {
            $.ajax({
                type: "get",
                url: b_url+"/columns/get_template?classpropertyid="+this.value,
                dataType:'json',
                beforeSend:
                        function() {
                        },
                success:
                        function(data) {
                            $('#classtemplateid').empty();
                            
                            $(data).each(function(){
                                $('#classtemplateid').prepend("<option value='"+this.classtemplateid+"'>"+this.templatename+"</option>");
                            });
                            $("#classtemplateid").prepend("<option value='-1' selected='selected'>请选择</option>"); 
                        }
            });
        }
        selete_tips($(this));
    });
    $('#classname,#classlinkname,#thumbwidth,#listid,#pagesize,#topnum,#titlenum,#descnum,#datalink').change(function() {
        input_tips($(this));
    });

    $('#form1').submit(function() {
        var is = true;
        if (!selete_tips($('#configid'))) {
            is = false;
        }
        if (!selete_tips($('#classpropertyid'))) {
            is = false;
        }
        if (!selete_tips($('#classtemplateid'))) {
            is = false;
        }

        if (!input_tips($('#classname'))) {
            is = false;
        }
        if (!input_tips($('#classlinkname'))) {
            is = false;
        }
        
        if (!input_tips($('#thumbwidth'))) {
            is = false;
        }
        if (!input_tips($('#listid'))) {
            is = false;
        }
        if (!input_tips($('#pagesize'))) {
            is = false;
        }
        if (!input_tips($('#topnum'))) {
            is = false;
        }
        if (!input_tips($('#titlenum'))) {
            is = false;
        }
        if (!input_tips($('#descnum'))) {
            is = false;
        }
        if (!input_tips($('#datalink'))) {
            is = false;
        }
        return is;
    });
</script>
<?php $this->load->view('layout/footer'); ?>
